package com.dhcc.DRGsHosp.facade.impl.assembler;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import com.dhcc.DRGsHosp.core.domain.Ward;
import com.dhcc.DRGsHosp.facade.dto.WardDTO;

public class WardAssembler {
	
	public static WardDTO  toDTO(Ward  ward){
		if (ward == null) {
			return null;
		}
    	WardDTO result  = new WardDTO();
	    	result.setWardCode(ward.getWardCode());
 	    	result.setWardDesc(ward.getWardDesc());
 	    	result.setDepCode(ward.getDepCode());
 	    	result.setDepGroupCode(ward.getDepGroupCode());
 	    	result.setDepGroupDesc(ward.getDepGroupDesc());
 	    	result.setDepName(ward.getDepName());
 	    	result.setWardResume(ward.getWardResume());
 	    	result.setWardOrder(ward.getWardOrder());
     	    return result;
	 }
	
	public static List<WardDTO>  toDTOs(Collection<Ward>  wards){
		if (wards == null) {
			return null;
		}
		List<WardDTO> results = new ArrayList<WardDTO>();
		for (Ward each : wards) {
			results.add(toDTO(each));
		}
		return results;
	}
	
	 public static Ward  toEntity(WardDTO  wardDTO){
	 	if (wardDTO == null) {
			return null;
		}
	 	Ward result  = new Ward();
	 	result.setWardCode(wardDTO.getWardCode());
    	result.setWardDesc(wardDTO.getWardDesc());
    	result.setDepCode(wardDTO.getDepCode());
    	result.setDepGroupCode(wardDTO.getDepGroupCode());
    	result.setWardResume(wardDTO.getWardResume());
    	result.setWardOrder(wardDTO.getWardOrder());
 	  	return result;
	 }
	
	public static List<Ward> toEntities(Collection<WardDTO> wardDTOs) {
		if (wardDTOs == null) {
			return null;
		}
		
		List<Ward> results = new ArrayList<Ward>();
		for (WardDTO each : wardDTOs) {
			results.add(toEntity(each));
		}
		return results;
	}
}
